/**
 * Created by losor on 2017/3/15.
 */
public class _434_NumberOfSegmentsInaString {

    public static void main(String[] args) {

    }

    public int countSegments(String s) {
        boolean isAlpha = false;
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (isAlpha)
            {
                if (s.charAt(i)==' '){
                    isAlpha = false;
                }
            }
            else{
                if (!(s.charAt(i)==' ')){
                    count++;
                    isAlpha= true;
                }
            }
        }
        return count;
    }
}
